﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RemoteTestRunnerDemo
{
    [TestClass]
    public class CompleteDemo
    {

        public TestContext TestContext { get; set; }

        private static RemoteTestRunner.UnitTesting.MultiAssertTestClassHelper _testClassHelper;

        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            _testClassHelper =
                new RemoteTestRunner.UnitTesting.MultiAssertTestClassHelper("CompletedDemo", testContext);
        }

        [ClassCleanup()]
        public static void MyClassCleanup()
        {
            _testClassHelper.Dispose();
        }

        [TestMethod]
        [DeploymentItem("RemoteTestRunnerDemo\\DemoData.xls")]
        [DataSource("DemoDataSource")]
        public void TestMethod0()
        {
            TestContext.WriteLine("Input1: {0}",
                TestContext.DataRow["Input1"].ToString());
        }

        [TestMethod]
        [DeploymentItem("RemoteTestRunnerDemo\\DemoData.xls")]
        [DataSource("DemoDataSource")]
        public void TestMethod1()
        {
            using (var functionHelper =
                _testClassHelper.GetFunctionHelper(TestContext))
            {

                functionHelper
                    .AddInput("Input1")
                    .AddInput("Input2", TestContext.DataRow["Input2"]);

                int input1 = functionHelper.FieldValue<int>("Input1");
                int input2 = Convert.ToInt32(TestContext.DataRow["input2"]);

                int result = input1 + input2;

                //functionHelper.AreEqual<int>(TestContext.DataRow["Output1"], result, "Sum of ints", "Output1");
                functionHelper.AreEqual<int>(result, "Sum of ints", "Output1");

            }
        }


        [TestMethod]
        [DeploymentItem("RemoteTestRunnerDemo\\DemoData.xls")]
        [DataSource("DemoDataSource")]
        public void TestMethod11()
        {
            using (var functionHelper = _testClassHelper.GetFunctionHelper(TestContext))
            {

                functionHelper
                    .AddInput("Input1")
                    .AddInput("Input2", TestContext.DataRow["Input2"]);

                int input1 = functionHelper.FieldValue<int>("Input1");
                int input2 = Convert.ToInt32(TestContext.DataRow["input2"]);

                int result = input1 + input2;

                functionHelper.AreEqual<int>(result, "Sum of ints", "Output1");
            }
        }
    }
}